﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CoastalClimbing.Code;

namespace CoastalClimbing
{
    public partial class Route : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string routeid = Request.QueryString["id"].ToString();

                    DataTable dt = DAL.RoutesSelectOne(routeid);

                    if(dt != null)
                    {
                        if(dt.Rows.Count > 0)
                        {
                            DataRow dr = dt.Rows[0];

                            lblRouteName.Text = dr["NAME"].ToString();
                            lblDescription.Text = string.Format("Route description: {0}", dr["DESCRIPTION"].ToString());
                            hyperWall.Text = dr["WALL"].ToString();
                            hyperWall.NavigateUrl = string.Format("~/Wall.aspx?id={0}", dr["WALLID"].ToString());
                            lblRating.Text = string.Format("Rating: {0}", dr["RATING"].ToString());
                            lblSetter.Text = string.Format("Setter: {0}", dr["SETTER"].ToString());
                            lblDateSet.Text = string.Format("Date set: {0:MM/dd/yyyy}", dr["DATESET"]);//(dr["DATESET"]? Convert.ToDateTime(dr["DATESET"]) : null));
                            lblDateExp.Text = string.Format("Date exp: {0:MM/dd/yyyy}", dr["DATEEXP"]);//Convert.ToDateTime(dr["DATEEXP"]));
                        }
                    }
                }
                catch
                {
                    lblRouteName.Text = "No route with this ID exists. Can't hack me!";
                }
            }
        }

        private void BindInfo(string routeid)
        {

        }
    }
}